package pri.hillchen.springbootstd.service.impl;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import pri.hillchen.springbootstd.entity.User;
import pri.hillchen.springbootstd.service.BaseService;

/**
 * Created by hillchen on 2017/10/15.
 */
public class BaseServiceImpl <M extends BaseMapper<T>, T> extends ServiceImpl<M , T> implements BaseService<T>{
    @Override
    public Page<T> selectPageHasTotal(Page<T> page) {
        page = selectPage(page);
        int total = selectCount(new EntityWrapper<T>());
        page.setTotal(total);
        return page;
    }

    @Override
    public Page<T> selectPageHasTotal(Page<T> page, Wrapper<T> wrapper) {
        page = selectPage(page,wrapper);
        int total = selectCount(wrapper);
        page.setTotal(total);
        return page;
    }
}
